﻿Imports System.Configuration

Namespace Configuration

    Public Class FormElement
        Inherits ConfigurationElement

        '<Form Name="Contact" UrlReferrer="/SilksterMS/silkster/Contact.aspx" IsActive="true">

        <ConfigurationProperty("Name", IsKey:=True, IsRequired:=True)> _
        Public Property Name() As String
            Get
                Return DirectCast(Me("Name"), String)
            End Get
            Set(ByVal value As String)
                Me("Name") = value
            End Set
        End Property

        <ConfigurationProperty("UrlReferrer", IsRequired:=True)> _
        Public Property UrlReferrer() As String
            Get
                Return DirectCast(Me("UrlReferrer"), String)
            End Get
            Set(ByVal value As String)
                Me("UrlReferrer") = value
            End Set
        End Property

        <ConfigurationProperty("IsActive", DefaultValue:="true", IsRequired:=False)> _
        Public Property IsActive() As Boolean
            Get
                Return DirectCast(Me("IsActive"), Boolean)
            End Get
            Set(ByVal value As Boolean)
                Me("IsActive") = value
            End Set
        End Property

        <ConfigurationProperty("Fields")> _
        Public ReadOnly Property Fields() As FieldCollection
            Get
                Return DirectCast(Me("Fields"), FieldCollection)
            End Get
        End Property

        <ConfigurationProperty("Recipients")> _
        Public ReadOnly Property Recipients() As RecipientCollection
            Get
                Return DirectCast(Me("Recipients"), RecipientCollection)
            End Get
        End Property

    End Class

    <ConfigurationCollection(GetType(FormElement))> _
    Public Class FormCollection
        Inherits ConfigurationElementCollection

        Protected Overloads Overrides Function CreateNewElement() As ConfigurationElement
            Return New FormElement()
        End Function

        Protected Overloads Overrides Function GetElementKey(ByVal element As ConfigurationElement) As Object
            Return DirectCast((element), FormElement).Name
        End Function

        Default Public Shadows ReadOnly Property Item(ByVal idx As Integer) As FormElement
            Get
                Return DirectCast(BaseGet(idx), FormElement)
            End Get
        End Property

    End Class

End Namespace
